# __author__ = 'heyin'
# __date__ = '2018/11/14 13:31'
# 不同维度的数据进行计算

import numpy as np

# np.random.seed(1)

# a = np.random.randint(0, 10, (3, 3, 3))
# print(a)
# b1 = np.random.randint(0, 10, (3, 1))
# b2 = np.random.randint(0, 10, (3,))
# b3 = np.random.randint(0, 10, (3, 3))
# b4 = np.random.randint(0, 10, (1, 1, 3))
# b4 = np.random.randint(0, 10, (3, 1, 3))
#
# print(b4)
# # print(b2)
# # print(b3)
#
# # print(a + b1)
# # print(a + b2)
# # print(a + b3)
# print(a + b4)
# c = np.array([[1, 2, np.nan], [np.nan, 1, 2]])
# print(c)
# print(c == c)
# print(np.count_nonzero(c != c))
# print(c.shape)
#
# print(np.isnan(c))
# # c[np.isnan(c)] = 0
# print(c)
#
# print(np.mean(c, axis=0))
# print(c.mean(axis=0))


import pandas as pd

# d = {'name': ['heyin', 'liu']}
# df = pd.DataFrame(data=d, index=[2, 20])
# print(df)
# print(df['name'].index)
# n = pd.DataFrame(data={'age': [1, 2]}, index=df['name'].index)
# print(n)
# df['age'] = n
# print(df)
#
#
#
# # where的使用方式
# g = np.arange(10)
# print(g)
# # print(np.where(g > 3))
# # print(np.where(g > 3))
# # print(np.where(g == 3))
# print(np.where(g >= 3, 3, 1))
# np.where([[True, False], [True, True]], [[1, 2], [3, 4]], [[9, 8], [7, 6]])

# a = np.arange(12).reshape((3, 4))
# print(a)
# b = a.reshape((-1, 4))
# print(b)
# c = a.reshape((4, -1))
# print(c)


# print(a.flatten())
# print(a.ravel())

# 二维数组tolist
# a = np.arange(12).reshape((3, 4))
# print(a)
# print(a.tolist())